﻿<%@ Page Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true" CodeBehind="CustomerTiered.aspx.cs" Inherits="Pariveda.DataAccess35.Web.CustomerTiered" Title="Customer Editor Using N-Tiers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainPlaceHolder" runat="server">
    <div id="Left">
        <asp:ListBox ID="CustomerListBox" runat="server" 
            AutoPostBack="true" AppendDataBoundItems="true" 
            OnSelectedIndexChanged="CustomerListBox_SelectedIndexChanged" />
    </div>
    <div id="Main">
        <asp:UpdatePanel ID="DetailUpdatePanel" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="CustomerListBox" EventName="SelectedIndexChanged" />
            </Triggers>
            <ContentTemplate>
                <div><asp:Label ID="MessageLabel" runat="server" CssClass="CommonMessage" EnableViewState="false" /></div>
                <asp:Panel ID="ChangeConflictPanel" runat="server" Visible="false" CssClass="ChangeException">
                    This customer record has changed since the results were retrieved from the database.
                    Do you want to save your changes now?
                    <p />
                    Click Yes to commit your changes to the database anyway.<br />
                    Click No to discard your change and retrieve the current data for this row.<br />
                    Click Cancel to continue editing.
                    <p />
                    <asp:Button ID="YesDataChangeButton" runat="server" Text="Yes" OnClick="YesDataChangeButton_Click" />&nbsp;<asp:Button
                        ID="NoDataChangeButton" runat="server" Text="No" OnClick="NoDataChangeButton_Click" />&nbsp;<asp:Button
                            ID="CancelDataChangeButton" runat="server" Text="Cancel" OnClick="CancelDataChangeButton_Click" />
                </asp:Panel>
                <div class="Form">
                    <div>
                        <label>
                            Company Name:</label>
                        <asp:TextBox ID="NameTextBox" runat="server" />
                    </div>
                    <div>
                        <label>
                            Email:</label>
                        <asp:TextBox ID="EmailTextBox" runat="server" />
                    </div>
                    <div>
                        <label>
                            First Name:</label>
                        <asp:TextBox ID="FirstNameTextBox" runat="server" />
                    </div>
                    <div>
                        <label>
                            Last Name:</label>
                        <asp:TextBox ID="LastNameTextBox" runat="server" />
                    </div>
                    <label>Addresses:</label>
                    <asp:ListView ID="AddressRepeater" runat="server" OnItemCommand="AddressRepeater_ItemCommand">
                        <LayoutTemplate>
                            <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                            <br />
                        </LayoutTemplate>
                        <ItemTemplate>
                            <div class="Address">
                                <div>
                                    <asp:TextBox ID="AddressLine1TextBox" runat="server" Text='<%# Eval("AddressLine1") %>'
                                        Width="265px" /></div>
                                <div>
                                    <asp:TextBox ID="AddressLine2TextBox" runat="server" Text='<%# Eval("AddressLine2") %>'
                                        Width="265px" /></div>
                                <div>
                                    <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Eval("City") %>' Width="100px" />,&nbsp;<asp:TextBox
                                        ID="StateTextBox" runat="server" Text='<%# Eval("StateProvince") %>' Width="100px" />&nbsp;&nbsp;<asp:TextBox
                                            ID="PostalCodeTextBox" runat="server" Text='<%# Eval("PostalCode") %>' Width="40px" /></div>
                                <div style="float: right">
                                    <asp:Button ID="DeleteAddressButton" runat="server" CommandName="Remove" Text="Delete"
                                        CommandArgument='<%# Container.DisplayIndex %>' Width="80px" /></div>
                            </div>
                        </ItemTemplate>
                    </asp:ListView>
                    <asp:Button ID="AddAddressButton" runat="server" Text="Add Address" OnClick="AddAddressButton_Click" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div id="CustomerButtons">
        <asp:Button ID="SaveButton" runat="server" Text="Save" OnClick="SaveButton_Click" />
        <asp:Button ID="DeleteButton" runat="server" Text="Delete" OnClick="DeleteButton_Click" OnClientClick="return confirm('Are you sure you want to delete this customer?');"/>
        </div>
    </div>
</asp:Content>
